﻿<?php	 
		
					   
			 
					 
	$abfrage = "SELECT * FROM x_games ORDER BY spielzeit DESC";
						 			 		
			 
			$ergebnis = mysql_query($abfrage)
				OR die("Error: $abfrage <br>".mysql_error());
				
				$cnt = 1;
			while($row = mysql_fetch_object($ergebnis))
			   {				 
				   	$phpdate = strtotime( $row->spielzeit );
					$time = date( 'd-m-Y', $phpdate );
					echo '<table id="rank" cellspacing="0" cellpadding="0" class="roundRobin">
					   <thead>
						  <tr>
							 <th class="first" scope="col"></th>
							 <th scope="col" text-align="left">'.$row->spielname.'</th>
							 <th scope="col">'.$row->spielort.'</th>
							 <th scope="col">'.$time.'</th>
							 <th class="last" scope="col">'.$row->bemerkung.'</th>
						  </tr>
					   </thead></tbody></table>';
				   
				   $abfrageG = "SELECT * FROM x_points WHERE spiel_id = '".$row->id."' ORDER BY position ASC";			 		
			 
					$ergebnisG = mysql_query($abfrageG)
						OR die("Error: $abfrage <br>".mysql_error());
					
					echo '<table id="rank" cellspacing="0" cellpadding="0" class="roundRobin">
					   <thead>
						  <tr>
							 <th class="first" scope="col">#</th>
							 <th scope="col">Team / WG</th>
							 <th scope="col">Punkte</th>
							 <th class="last" scope="col">Kommentar</th>
						  </tr>
						</thead>					   
					   <tfoot>
						  <tr>
							 <td class="first"></td>
							 <td colspan="2"></td>
							 <td class="last"></td>
						  </tr>
					   </tfoot><tbody>';

					while($rowG = mysql_fetch_object($ergebnisG))
					   {				 

				   
					  echo '<tr class="rowA">
						 <td class="first">'.$rowG->position.'</td>
						 <td>'.$rowG->team_id.'</td>
						 <td><input type="text" value='.$rowG->points.' readonly></td>
						 <td class="last">'.$rowG->bemerkung.'</td>
						</tr>';
					   }
			   }
			   echo '</tbody></table><br/>';
			   
		 ?>